package com.minibobbo.utilities.spe.aimodules;

import com.badlogic.gdx.math.Vector2;
import com.minibobbo.utilities.spe.SpeDynamicObject;

public class SpeAIMoveTowards extends SpeAIModule {

	private SpeDynamicObject target;
	private Vector2 targetLoc;

	@Override
	public void updateAI(float delta) {
		parent.resetMovementVariables();
		if (parent.loc.getCenter().x > target.loc.getCenter().x
				&& Math.abs(parent.loc.x - target.loc.x) >.8f)
			parent.l = true;
		if (parent.loc.getCenter().x < target.loc.getCenter().x
				&& Math.abs(parent.loc.x - target.loc.x) >.8f)
			parent.r = true;
		if (parent.loc.getCenter().y > target.loc.getCenter().y
				&& Math.abs(parent.loc.y - target.loc.y) >.8f)
			parent.d = true;
		if (parent.loc.getCenter().y < target.loc.getCenter().y
				&& Math.abs(parent.loc.y - target.loc.y) >.8f)
			parent.u = true;

	}

	public void setTarget(SpeDynamicObject target) {
		this.target = target;

	}

	public void setTargetPoint(float x, float y) {
		targetLoc = new Vector2(x, y);
	}

}
